package com.java110.mall.goods.cmd.housekeepingServ;

import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.dto.housekeeping.HousekeepingServDto;
import com.java110.mall.goods.bmo.housekeepingServ.IGetHousekeepingServBMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;

@Java110Cmd(serviceCode = "housekeepingServ.queryHousekeepingServ")
public class QueryHousekeepingServCmd extends Cmd {

    @Autowired
    private IGetHousekeepingServBMO getHousekeepingServBMOImpl;

    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
        super.validatePageInfo(reqJson);
    }

    @Override
    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
        HousekeepingServDto housekeepingServDto = BeanConvertUtil.covertBean(reqJson, HousekeepingServDto.class);
       String createTime = reqJson.getString("createTime");

        if (null != createTime && !"".equals(createTime)) {
            housekeepingServDto.setCreateTime(DateUtil.getDateFromStringB(createTime));
        }

        ResponseEntity<String> response = getHousekeepingServBMOImpl.get(housekeepingServDto);
        context.setResponseEntity(response);
    }
}
